[Unit]
Description=Patch firmware for brcm40183 Bluetooth adapter
Before=bluetooth.service

[Service]
Environment=MAC_ADDR=11:22:33:44:55:66
Environment=PORT=/dev/ttyS1
EnvironmentFile=/etc/default/brcm40183
TimeoutStartSec=60
Type=simple
ExecStartPre=/usr/bin/brcm_bt_reset /dev/${PORT}
ExecStartPre=/bin/echo -en "" > /dev/${PORT}
ExecStartPre=/usr/bin/brcm_patchram_plus -d --patchram /lib/firmware/ap6210/bcm20710a1.hcd --no2bytes --tosleep 1000 --bd_addr ${MAC_ADDR} /dev/${PORT}
ExecStart=/usr/bin/hciattach -n /dev/${PORT} any
ExecStart=/usr/bin/rfkill unblock all

[Install]
WantedBy=bluetooth.target
